package o;

import androidx.annotation.NonNull;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import com.huawei.appgallery.foundation.card.base.bean.AppInfoBean;
import java.util.List;
import o.cof.d;

public class dtz$a implements cdt {
    public void ˊ(int i, @NonNull Object obj) {
        if (obj instanceof SessionDownloadTask) {
            ˋ((SessionDownloadTask) obj);
        } else {
            Logger.ˋ("APP_SYN", dtz.ʻ() + "not deal download message");
        }
    }

    private void ˋ(SessionDownloadTask sessionDownloadTask) {
        switch (sessionDownloadTask.ˈ()) {
            case 4:
                Logger.ˋ("APP_SYN", dtz.ʻ() + " handleMessage downloaded pkg=" + sessionDownloadTask.ˊˊ() + " start install.....");
                ˎ(sessionDownloadTask);
                dtz.ˎ(dtz.ॱ(), ˊ(sessionDownloadTask));
                return;
            case 5:
                Logger.ˋ("APP_SYN", dtz.ʻ() + " handleMessage downloadfailed pkg=" + sessionDownloadTask.ˊˊ());
                dtz.ˎ(dtz.ॱ(), ˊ(sessionDownloadTask));
                return;
            default:
                return;
        }
    }

    private void ˎ(SessionDownloadTask sessionDownloadTask) {
        int ˏ = etn.ˏ(3);
        coi o_dtz_c = new dtz$c();
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            cnw o_cnw = (cnw) ˋ.ॱ(cnw.class);
            if (o_cnw != null) {
                List<SplitTask> ᐝˊ = sessionDownloadTask.ᐝˊ();
                if (!CollectCheck.isEmpty(ᐝˊ)) {
                    d ˏ2 = new d().ˋ(sessionDownloadTask.ˊˊ()).ˏ(sessionDownloadTask.ॱᐝ()).ˊ(ˏ).ˊ(coc.ˋ).ˏ(o_dtz_c);
                    for (SplitTask splitTask : ᐝˊ) {
                        ˏ2.ॱ(splitTask.ॱˊ(), splitTask.ॱᐝ(), splitTask.ᐝॱ());
                    }
                    o_cnw.ˋ(ContentManager.getInstant().getContext(), ˏ2.ˎ());
                    return;
                }
                return;
            }
            Logger.e(dtz.ʻ(), "can not found IPackageInstaller Api");
            return;
        }
        Logger.e(dtz.ʻ(), "can not found PackageManager module");
    }

    private AppInfoBean ˊ(SessionDownloadTask sessionDownloadTask) {
        if (sessionDownloadTask == null) {
            Logger.ˋ("APP_SYN", dtz.ʻ() + " turnToAppInfoBean bean is null");
            return null;
        }
        AppInfoBean appInfoBean = new AppInfoBean();
        List ᐝˊ = sessionDownloadTask.ᐝˊ();
        if (!CollectCheck.isEmpty(ᐝˊ)) {
            SplitTask splitTask = (SplitTask) ᐝˊ.get(0);
            appInfoBean.ʼ(splitTask.ᐝ());
            appInfoBean.ॱॱ(splitTask.ॱॱ());
            appInfoBean.ʻ(String.valueOf(splitTask.ʼ()));
        }
        appInfoBean.ˏ(sessionDownloadTask.ʿ());
        appInfoBean.ˋ(sessionDownloadTask.ˊˊ());
        appInfoBean.ʽ(sessionDownloadTask.ॱˋ());
        appInfoBean.ˊ(sessionDownloadTask.ˎˎ());
        appInfoBean.ॱ(String.valueOf(sessionDownloadTask.ॱᐝ()));
        appInfoBean.ˋ(sessionDownloadTask.ˋ());
        return appInfoBean;
    }
}
